<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="java.io.*,java.sql.*,java.util.*,java.net.*,java.text.*"%>
<%@ page import="com.yuxin.common.util.*" %>
<%@ page import="com.yuxin.core.exception.SiteRuntimeException" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
    Connection conn = DBUtil.getConnection();
    String tradeId = request.getParameter("tradeId");// 分类ID
    try{
        Map tradeMap = DBUtil.queryUniqueResult(conn,"SELECT NAME,LICENSE_IMG FROM P_TRADE WHERE ID = ? ",tradeId);
        List<Map<String,Object>> classList = DBUtil.queryList(conn,"SELECT DISTINCT(P_CLASS) FROM P_GOODS WHERE TRADE_ID = ? AND `STATUS` = '2' ORDER BY P_CLASS",tradeId);
        for(Map cMap : classList){
        	int pClass = Integer.parseInt(cMap.get("P_CLASS").toString());
        	switch(pClass){
	        	case 1:
	        		cMap.put("CLASS_NAME","中餐");
	        		cMap.put("ENCODE_CLASS_NAME",URLDecoder.decode("中餐", "UTF-8"));
	        		break;
	        	case 2:
	        		cMap.put("CLASS_NAME","西餐");
	        		cMap.put("ENCODE_CLASS_NAME",URLDecoder.decode("西餐", "UTF-8"));
	        		break;
	        	case 3:
	        		cMap.put("CLASS_NAME","蛋糕甜");
	        		cMap.put("ENCODE_CLASS_NAME",URLDecoder.decode("蛋糕甜", "UTF-8"));
	        		break;
	        	case 4:
	        		cMap.put("CLASS_NAME","自助餐");
	        		cMap.put("ENCODE_CLASS_NAME",URLDecoder.decode("自助餐", "UTF-8"));
	        		break;
	        	case 5:
	        		cMap.put("CLASS_NAME","火锅");
	        		cMap.put("ENCODE_CLASS_NAME",URLDecoder.decode("火锅", "UTF-8"));
	        		break;
	        	case 6:
	        		cMap.put("CLASS_NAME","酒店");
	        		cMap.put("ENCODE_CLASS_NAME",URLDecoder.decode("酒店", "UTF-8"));
	        		break;
	        	case 7:
	        		cMap.put("CLASS_NAME","旅游");
	        		cMap.put("ENCODE_CLASS_NAME",URLDecoder.decode("旅游", "UTF-8"));
	        		break;
	        	case 8:
	        		cMap.put("CLASS_NAME","电影票");
	        		cMap.put("ENCODE_CLASS_NAME",URLDecoder.decode("电影票", "UTF-8"));
	        		break;
	        	case 9:
	        		cMap.put("CLASS_NAME","教育培训");
	        		cMap.put("ENCODE_CLASS_NAME",URLDecoder.decode("教育培训", "UTF-8"));
	        		break;
	        	case 10:
	        		cMap.put("CLASS_NAME","体检保健");
	        		cMap.put("ENCODE_CLASS_NAME",URLDecoder.decode("体检保健", "UTF-8"));
	        		break;
	        	case 11:
	        		cMap.put("CLASS_NAME","美容SPA");
	        		cMap.put("ENCODE_CLASS_NAME",URLDecoder.decode("美容SPA", "UTF-8"));
	        		break;
	        	case 12:
	        		cMap.put("CLASS_NAME","美发");
	        		cMap.put("ENCODE_CLASS_NAME",URLDecoder.decode("美发", "UTF-8"));
	        		break;
        	}
        	List<Map<String,Object>> goodsList = DBUtil.queryList(conn,"SELECT ID,TITLE,TITLE_IMG,PRICE,AMOUNT,UPDATE_TIME FROM P_GOODS WHERE TRADE_ID = ? AND P_CLASS = ? AND `STATUS` = '2' ORDER BY UPDATE_TIME DESC LIMIT 0,6 ",tradeId,pClass);
        	cMap.put("goodsList",goodsList);
        }
        request.setAttribute("titleName",URLDecoder.decode(tradeMap.get("NAME").toString(), "UTF-8"));
        request.setAttribute("tradeMap",tradeMap);
        request.setAttribute("classList",classList);
    }catch (Exception e){
        e.printStackTrace();
        throw new SiteRuntimeException(e);
    }finally {
        DBUtil.close(conn);
    }
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>${titleName}</title>
    <meta name="Keywords" content="中信信用卡平台" />
    <meta name="Description" content="${titleName}"/>
    <meta name="robots" content="all"/>
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="format-detection" content="telephone=no"/>
    <meta http-equiv="cleartype" content="on"/>
    <link rel="icon" type="image/png" href="images/favicon.ico">
    <%@ include file="/site/css.jsp" %>
    <style type="text/css">
    	.column-list li img{height:80px;}
    	.column-list li .name{font-size:11pt;text-overflow:ellipsis;-o-text-overflow:ellipsis;white-space:nowrap;overflow:hidden;}
    	.column-list li .price{font-size:10pt;overflow:hidden;display:block;color:#EA8511;padding-top:2px;font-size: 12pt;font-weight:600;}
    </style>
</head>
<body>
<div id="page">
    <%@ include file="/site/header_nav.jsp" %>
    <div id="brand">
        <img style="width: 100%;" src="${ctx}${tradeMap.LICENSE_IMG}" align="absmiddle"/>
    </div>
    <c:forEach items="${classList}" var="data" varStatus="status">
	    <div id="news" style="padding:0 8px;">
	        <div class="news-title bg-ffd236">
	        	<a class="clearfix more bg-ffd236" href="${ctx}/site/shangpin_lb.jsp?pClass=${data.P_CLASS}&name=${data.ENCODE_CLASS_NAME}">
		            <span style="margin-left:10px;" class="left">${data.CLASS_NAME}</span>
	                <span class="right"><img src="${ctx}/site/css/bg/right2.png"></span>
	        	</a>
	        </div>
	    </div>
	    <div style="margin:0 auto;width:100%;max-width:800px;">
		    <ul class="column-list column-list-col3">
	            <c:forEach items="${data.goodsList}" var="goods" varStatus="status">
		     		<li>
		     			<a class="cont" href="${ctx}/site/shangpin_x.jsp?id=${goods.ID}">
			                <c:if test="${goods.TITLE_IMG !=null && goods.TITLE_IMG !=''}">
			                    <img src="${ctx}${goods.TITLE_IMG}.s.jpg" align="absmiddle"/>
			                </c:if>
			   				<div style="font-size:11pt;">${goods.TITLE}</div>
			   				<div class="price" style="font-size:10pt;">￥${goods.PRICE}</div>
		                 </a>
		    		</li>
	            </c:forEach>
			</ul>
		</div>
    </c:forEach>
    <%@ include file="/site/footer.jsp" %>
</div>
</body>
<%@ include file="/site/js.jsp" %>
</html>